<template>
    <el-alert
            v-show="show"
            :title="content"
            :type="type">
    </el-alert>
</template>

<script>
    export default {
        name: "my-alert",
        data() {
            return {show: false, content: '', type: 'error'};
        },
        methods: {
            success(content, hide) {
                this.show = true;
                this.content = content;
                this.type = 'success';
                if (hide > 0)
                    setTimeout(() => {
                        this.show = false;
                    }, hide);
            },
            error(content, hide) {
                this.show = true;
                this.content = content;
                this.type = 'error';
                if (hide > 0)
                    setTimeout(() => {
                        this.show = false;
                    }, hide);
            },
            hide() {
                this.show = false;
            }
        }
    }
</script>

<style scoped>

</style>